﻿#define DEBUG_AGENT
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
using System.IO;
using LocalSettings;
using Microsoft.Phone.Shell;
using System.Linq;
using QuickTasks.ViewModels.Tables;

namespace QuickTasks
{
    
    public class DataHelper
    {
        IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
      
        QuickTaskDataContext context = new QuickTaskDataContext(App.ConnectionString);
        public  void MoveReferenceDatabase()
        {
            try
            {


                if (!iso.FileExists("quick.sdf"))
                {
                    using (Stream input = Application.GetResourceStream(new Uri("quick.sdf", UriKind.Relative)).Stream)
                    {

                        using (IsolatedStorageFileStream output = iso.CreateFile("quick.sdf"))
                        {

                            byte[] readBuffer = new byte[4096];
                            int bytesRead = -1;


                            while ((bytesRead = input.Read(readBuffer, 0, readBuffer.Length)) > 0)
                            {
                                output.Write(readBuffer, 0, bytesRead);
                            }
                        }
                    }
                }
        
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in MoveReferenceDatabase method In DataHelper file", ex);
            }
                
            
        }
        

        }
    }

